package com.jiaija;

/**
 * jvm 参数 ：
 *      -XX: +printGCDetails
 * @author : zjj
 * @date : 2022/5/6 15:09
 */
public class Demo02LocalVarGC {

    public void localvarGC1() {
        byte[] buffer = new byte[10 * 1024 * 1024];//10MB
        System.gc();
    }

    public void localvarGC2() {
        byte[] buffer = new byte[10 * 1024 * 1024];
        buffer = null;
        System.gc();
    }

    public void localvarGC3() {
        {
            byte[] buffer = new byte[10 * 1024 * 1024];
        }
        // 这里的buffer不能被回收，变量还是引用 着对象
        System.gc();
    }

    public void localvarGC4() {
        {
            byte[] buffer = new byte[10 * 1024 * 1024];
        }
        int value = 10;
        // 可以回收 ，buffer变量的槽位呗 value占用了
        System.gc();
    }

    public void localvarGC5() {
        localvarGC1();
        System.gc();
    }

    public static void main(String[] args) {
        Demo02LocalVarGC local = new Demo02LocalVarGC();
        local.localvarGC5();
    }


}
